package com.sean.learnelasticsearch.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sean.learnelasticsearch.entity.Article;
import com.sean.learnelasticsearch.mapper.ArticleMapper;
import com.sean.learnelasticsearch.service.IArticleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文章 service 实现类
 *
 * @author 林思瀚 (linsihan@cndatacom.com)
 * @date 2023-09-21 10:48:37
 */
@Service
public class IArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements IArticleService {
    @Override
    public List<Article> getLastCreateArticles(int count) {
        QueryWrapper<Article> articleQueryWrapper = new QueryWrapper<>();
        articleQueryWrapper.orderByDesc("create_time");
        articleQueryWrapper.last("limit 0, " + count);
        return this.getBaseMapper().selectList(articleQueryWrapper);
    }
}
